package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.EmployeesRepository;
import org.example.petitionplatformsystem.dao.model.Employees;
import org.example.petitionplatformsystem.service.EmployeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeesServiceImpl implements EmployeesService {
    @Autowired
    private EmployeesRepository employeesRepository;
    @Override
    public void addEmployee(Employees employee) {
        employeesRepository.save(employee);
    }

    @Override
    public void deleteEmployee(long id) {
       employeesRepository.deleteById(id);
    }

    @Override
    public void updateEmployee(Employees employee) {
       employeesRepository.save(employee);
    }

    @Override
    public Employees getEmployeeById(long id) {
        return employeesRepository.findById(id).orElse(null);
    }

    @Override
    public List<Employees> getAllEmployees() {
        return employeesRepository.findAll();
    }
}
